PAU	EQU	#13
	ORG	#8000
;
	DI
	LD	BC,#FFFD
	LD	A,#07
	OUT	(C),A
	LD	A,B
	LD	B,#BF
	OUT	(C),A
	LD	BC,#FFFD
	LD	D,#00
LOOP1
	LD	HL,#C000
FORSAMP	EQU	$-2
LOOP
	LD	E,#08
	OUT	(C),E
	LD	A,#87
FORTONE	EQU	$-1
	ADD	A,D
	LD	D,A
	LD	A,#01
	ADC	A,L
	LD	L,A
	ADC	A,H
	SUB	L
	LD	H,A
	LD	A,(HL)
	PUSH	BC
	LD	B,PAU
PAUSE	DJNZ	PAUSE
	POP	BC
	OR	A
	OUT	(#FD),A
	JR	NZ,LOOP
;
	LD	A,127
	IN	A,(#FE)
	BIT	0,A
	JR	Z,EXIT
	BIT	1,A
	CALL	Z,MORE
	BIT	2,A
	CALL	Z,SMALL
	BIT	3,A
	CALL	Z,MORE2
	BIT	4,A
	CALL	Z,SMALL2
	JR	LOOP1
EXIT
	EI
	RET
;
MORE
	LD	HL,(FORSAMP)
	PUSH	BC
	LD	BC,#100
	ADD	HL,BC
	POP	BC
	LD	(FORSAMP),HL
	RET
SMALL
	LD	HL,(FORSAMP)
	PUSH	BC
	LD	BC,#100
	SBC	HL,BC
	POP	BC
	LD	(FORSAMP),HL
	RET
MORE2
	LD	A,(FORTONE)
	ADD	A,8
	LD	(FORTONE),A
	RET
SMALL2
	LD	A,(FORTONE)
	SUB	8
	LD	(FORTONE),A
	RET

